package com.android.zweibo.ui;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.RadioGroup;
import android.widget.TabHost;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TabHost.TabSpec;
/**
 * 
 * @author zxf
 *
 */
public class MainActivity extends TabActivity {
	private final String HOME_TAB = "home"; 
	private final String MSG_TAB = "msg";
	private final String AT_TAB = "at";
	private final String MORE_TAB = "more";
	private TabHost tabHost;
	private RadioGroup radioGroup;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    	// TODO Auto-generated method stub
    	super.onCreate(savedInstanceState);
    	setContentView(R.layout.main);
    	tabHost = this.getTabHost();
    	
    	TabSpec  home_TS = tabHost.newTabSpec(HOME_TAB).setIndicator(HOME_TAB).setContent(new Intent(this,HomeActivity.class));
    	TabSpec  msg_TS = tabHost.newTabSpec(MSG_TAB).setIndicator(MSG_TAB).setContent(new Intent(this,MsgActivity.class));
    	TabSpec  at_TS = tabHost.newTabSpec(AT_TAB).setIndicator(AT_TAB).setContent(new Intent(this,AtActivity.class));
    	TabSpec  more_TS = tabHost.newTabSpec(MORE_TAB).setIndicator(MORE_TAB).setContent(new Intent(this,MoreActivity.class));
    	
    	tabHost.addTab(home_TS);
    	tabHost.addTab(msg_TS);
    	tabHost.addTab(at_TS);
    	tabHost.addTab(more_TS);
    	
    	radioGroup = (RadioGroup) this.findViewById(R.id.rg_main_btn);
    	
    	radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				switch (checkedId){
				
				case R.id.home_main_btn:					
					tabHost.setCurrentTabByTag(HOME_TAB);
					break;
					
				case R.id.msg_main_btn:
					tabHost.setCurrentTabByTag(MSG_TAB);
					break;
					
				case R.id.at_main_btn:
					tabHost.setCurrentTabByTag(AT_TAB);
					break;
					
				case R.id.more_main_btn:
					tabHost.setCurrentTabByTag(MORE_TAB);
					break;
				}
			}
		});

    }
}
